home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
RTX2000.ZIP
/
rtx2000
/
monitor
/
util
< prev
Wrap
Text File
|
1992-11-01
|
2KB
|
106 lines
( **************************** MODULE UTIL ******************************
Utilities
)
xlink
: newline ( -- )
( Send new line to terminal )
CR emit LF emit
;
xlink
: toupper ( c -- c )
( Forces character to upper case )
dup 0x61 u>= if
0x20 - ( Lower case to uppercase )
then
;
xlink
: .x ( n -- )
( Print a hex number followed by a space )
4 for
dup 0xF and
dup 10 u>= if
7 + ( Adjust for A-F )
then
0x30 +
swap 4>> ( Next nibble )
next
drop
emit emit emit emit
0x20 emit ( print a space )
;
: skip_space ( a -- a )
( Skips past any spaces in the array pointer by the input )
begin
c@+ swap
0x20 -
until
1 -
;
xlink
: emit_string ( a -- )
( Output string pointed by a )
c@+ swap
for
c@+ swap emit
next
drop
;
: do_nibble ( n c o -- n f )
( Subtract offset o from c, incorporate it into number n, append FALSE )
- swap 4<< or FALSE
;
: do_digit ( n c -- n f )
( If c is a valid hex digit, incorporate it into number n and return FALSE
otherwise n not changed and TRUE returned )
dup 0x30 u>= if
dup 0x46 u<= if
dup 0x40 u>= if
dup 0x40 u<= if
drop TRUE
else
0x37 do_nibble
then
else
0x30 do_nibble
then
else
drop TRUE
then
else
drop TRUE
then
;
: getnum ( a -- n a )
( Get a number from the buffer address a , returns zero if none available
advances to first invalid hex digit )
skip_space ( Skip spaces )
0
begin
swap
c@+ -rot ( Get a char )
do_digit ( Fold it into the number )
until ( Repeat until invalid hex digit )
swap
1 -
;
: cpy_ram_ram ( d s c -- )
( Copy RAM to RAM, c=word count, s=source addr, d=destination addr )
for
@+
swap rot
!+ swap
next
drop drop
;